package com.huanong.mapper;

import com.huanong.pojo.Company;
import com.huanong.pojo.ConTact;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * 公司简介和联系我们模块相关的Mapper
 */
@Repository
public interface IntroductionMapper {

    @Select("select * from company where cyid=#{CyId}")
    Company companyQueryById(@Param("CyId") Integer CyId);

    @Select("select * from company")
    List<Company> companyQuery();

    @Insert("insert into company (cytime,cymessage) values(#{CyTime},#{CyMessage})")
    Integer addCompany(Company company);

    @Delete("delete from company where cyid=#{CyId}")
    int deleteCompany(@Param("CyId") Integer CyId);

    @Update("update company set cymessage=#{CyMessage} where cyid=#{CyId}")
    int updateCompany(Company company);

    @Select("select * from contact")
    List<ConTact> queryContact();

    @Select("select * from contact where ctid=#{CtId}")
    ConTact queryContactById(@Param("CtId") Integer CtId);

    @Insert("insert into contact (ctadd,ctcall,ctemail,ctlocation) values(#{CtAdd},#{CtCall},#{CtEmail},#{CtLocation})")
    int addContact(ConTact conTact);

    @Delete("delete from contact where ctid=#{CtId}")
    int deleteContact(@Param("CtId") Integer CtId);

    @Update("update contact set ctadd=#{CtAdd},ctcall=#{CtCall},ctemail=#{CtEmail},ctlocation=#{CtLocation} where ctid=#{CtId}")
    int updateContact(ConTact conTact);

    @Select("SELECT  * FROM `company` ORDER BY cytime DESC LIMIT 1")
    Company queryByTime();
}
